import java.util.Scanner;

public class Main {
    
    class TreeNode {
        public char val;
        public TreeNode left;
        public TreeNode right;

        public TreeNode(char val) {
            this.val = val;
        }
    }
    
    public  int i = 0;//不建议定义静态的成员变量 
    
    public  TreeNode createTree(String s) {
        TreeNode root = null;
        if(s.charAt(i) != '#') {
            root = new TreeNode(s.charAt(i));
            i++;
            root.left = createTree(s);
            root.right = createTree(s);
        } else {
            i++;
        }
        return root;
    }
    
    public  void inorder(TreeNode root) {
        if(root == null) return;
        inorder(root.left);
        System.out.print(root.val+" ");
        inorder(root.right);
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNextLine()) {
            String s = scan.nextLine();
            Main m = new Main();
            TreeNode root = m.createTree(s);
            m.inorder(root);
        }
    }
}
